package com.atguigu.gmall.user.service.impl;

import com.atguigu.gmall.model.user.UserInfo;
import com.atguigu.gmall.user.mapper.UserMapper;
import com.atguigu.gmall.user.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

/**
 *
 * 用户信息管理service 组件
 * @author : zjj
 * @date : 2021/2/3 9:19
 */

@Service
public class UserServiceImpl implements UserService {
    /**
     * 用户信息管理mapper组件
     */
    @Autowired
    private UserMapper userMapper;


    @Override
    public UserInfo login(UserInfo userInfo) {

        String password = userInfo.getPasswd();
        String newPwd = DigestUtils.md5DigestAsHex(password.getBytes());

        QueryWrapper query = new QueryWrapper();

        query.eq("login_name",userInfo.getLoginName());
        query.eq("passwd",userInfo.getPasswd());

        UserInfo user = userMapper.selectOne(query);

        return user;
    }
}
